<template>
  <div class="screen-full" @click.stop.prevent="toggleScreen">
    <i :class="isFull?'el-icon-help':'el-icon-s-help'" />
  </div>
</template>
<script>
import screenfull from 'screenfull'
export default {
  name: '',
  data() {
    return {
      isFull: false
    }
  },
  created() {
    // ESC会改变当前的全屏状态
    // screenfull是插件，它自带事件监听 on
    // screenfull.isFullscreen ：插件自带的属性，表示当前是否处于全屏状态
    screenfull.on('change', () => {
      // console.log('当前是否是全屏', screenfull.isFullscreen)
      this.isFull = screenfull.isFullscreen
    })
  },
  methods: {
    toggleScreen() {
      screenfull.toggle()
      this.isFull = !this.isFull
    }
  }
}
</script>
<style lang="scss" scoped>
.screen-full {
  display: inline-block;
  color: #cccccc;
  font-size: 20px;
  margin-right: 15px;
}
</style>
